package com.gdufs.secondhandwebsite.dao;

import com.gdufs.secondhandwebsite.entity.Goods;
import com.gdufs.secondhandwebsite.entity.Post;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class testPostMapper {

    @Autowired
     PostMapper postMapper;
    @Test
    public void TestCreatNewPost(){
        Post post=new Post();
      post.setPostTitle("超舞");
      post.setPostContent("测试");
        System.out.println(post);
      System.out.println(postMapper.CreatePost(post));
    }
//    int DeletePostByPrimaryKey(Long postId);
//    Post SelectPostByPrimaryKey(Long PostId);
//    int UpdatePostSelective(Post Post);
//    List<Post> getAllPost();
    @Test
    public void TestUpdatePostSelective(){
        Post post = postMapper.SelectPostByPrimaryKey(1L);
        post.setLikeNum(post.getLikeNum()+1);
        postMapper.UpdatePostSelective(post);
    }
   @Test
   public void getAllGoods(){
        List<Post> a = postMapper.getAllPost();
        for(Post each:a){
            System.out.println(a);
        }
    }

}
